using Microsoft.AspNetCore.Mvc;

namespace ConfigWebApi.Controllers;

[ApiController]
public class HomeController : ControllerBase
{
    private readonly ILogger<HomeController> _logger;
    private readonly IConfiguration _config;

    public HomeController(ILogger<HomeController> logger, IConfiguration configuration)
    {
        _logger = logger;
        _config = configuration;
    }


    [HttpGet("/")]
    public IActionResult Index()
    {
        _logger.LogTrace("这是一条【Trace】测试日志");
        _logger.LogDebug("这是一条【Debug】测试日志");
        _logger.LogInformation("这是一条【Info】测试日志");
        _logger.LogWarning("这是一条【Warn】测试日志");
        _logger.LogError("这是一条【Error】测试日志");
        _logger.LogCritical("这是一条【Critical】特别严重问题");

        var c1 = _config.GetConnectionString("Default");
        var c2 = _config["Logging:LogLevel:Default"];
        var c3 = _config["JWT:SecretKey"];
        return Ok(new {c1,c2,c3});
    }

}